﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TomatoClock.Models
{
    public class Achievement
    {
        public int AchievementId { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public Image Image { get; set; }
        public string ImagePath { get; set; } // 图片路径
        public Func<Data, bool> IsAchieved { get; set; }
        public Achievement()
        {
            
        }
        public Achievement(int achievementId, string name, string description, String ImageUrl)
        {
            AchievementId = achievementId;
            Name = name;
            Description = description;
            ImagePath = ImageUrl;
            Image = LoadImage(ImagePath);
        }
        private Image LoadImage(string fileName)
        {
            try
            {
                // 从文件加载图像
                return Image.FromFile(fileName);
            }
            catch (Exception ex)
            {
                // 处理图像加载错误
                MessageBox.Show($"Error loading image {fileName}: {ex.Message}");
                return null;
            }
        }
    }
}
